commands/test: Stack overflow due to unlimited recursion depth
authorLidong Chen <lidong.chen@oracle.com>
Mon, 16 Dec 2024 20:22:41 +0000 (20:22 +0000)
committerFelix Zielcke <fzielcke@z-51.de>
Wed, 11 Jun 2025 15:42:34 +0000 (17:42 +0200)
commita63134e2ad7406c49a43be586851c4ee95cb8012
tree82dfb35420cd746f915213b25e9859190bc76951
parentc51e33a6ed454670ba2b8c28e1538e086058b4dc
commands/test: Stack overflow due to unlimited recursion depth

The test_parse() evaluates test expression recursively. Due to lack of
recursion depth check a specially crafted expression may cause a stack
overflow. The recursion is only triggered by the parentheses usage and
it can be unlimited. However, sensible expressions are unlikely to
contain more than a few parentheses. So, this patch limits the recursion
depth to 100, which should be sufficient.

Reported-by: Nils Langius <nils@langius.de>
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Gbp-Pq: Topic cve-2025-jan
Gbp-Pq: Name commands-test-Stack-overflow-due-to-unlimited-recursion-d.patch
grub-core/commands/test.c